<!DOCTYPE html>
<html>
<head>
    <title>K8s Pod Dashboard</title>
    <style>
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        tr:nth-child(even) { background-color: #f9f9f9; }
    </style>
</head>
<body>
    <h1>Kubernetes Pod 查询</h1>
    <input type="text" id="namespace" placeholder="输入命名空间 (默认: default)" />
    <button onclick="loadPods()">查询</button>
    <div id="pod-table"></div>

    <script>
        async function loadPods() {
            const namespace = document.getElementById('namespace').value || 'default';
            const response = await fetch(`/api/pods?namespace=${namespace}`);
            const data = await response.json();
            
            let html = '<table><tr><th>Pod 名称</th><th>状态</th><th>Pod IP</th><th>节点</th></tr>';
            data.pods.forEach(pod => {
                html += `
                    <tr>
                        <td>${pod.name || '-'}</td>
                        <td>${pod.status || '-'}</td>
                        <td>${pod.pod_ip || '-'}</td>
                        <td>${pod.node_name || '-'}</td>
                    </tr>
                `;
            });
            html += '</table>';
            document.getElementById('pod-table').innerHTML = html;
        }
    </script>
</body>
</html>